package controller

import (
	"cms/core/response"
	"cms/core/upload"
	"github.com/gin-gonic/gin"
)

func Upload(ctx *gin.Context)  {
	fs, err := ctx.FormFile("file")
	if err != nil {
		response.Error(ctx, err)
		return
	}
	dst, err := upload.Save(ctx, fs, "images")
	if err != nil {
		response.Error(ctx, err.Error())
		return
	}

	response.Success(ctx, gin.H{
		"url": dst,
	})
}
